<template>
	<view class="content">
		<view class="my_list clear-both"  @tap="changeOtherHeadimg()">
			<view class="float-l clear-both">
				<image src="/static/tabbar/index/editheader.png" mode="aspectFill" class="listimg float-l"></image>
				<text class="fs16 color3 my_lists float-l">修改头像</text>
			</view>
			<view class="float-r clear-both">
				<image :src="headimg" mode=" aspectFill" class="listimg2 float-l"></image>
				<image src="/static/tabbar/index/enter.png" mode="aspectFill" class="listimg float-r"></image>
			</view>
		</view>
		<view class="my_list clear-both"  @tap="resetLoginPwd()">
			<view class="float-l clear-both">
				<image src="/static/tabbar/index/editps.png" mode="aspectFill" class="listimg float-l"></image>
				<text class="fs16 color3 my_lists float-l">修改密码</text>
			</view>
			<view class="float-r clear-both">
				<image src="/static/tabbar/index/enter.png" mode="aspectFill" class="listimg float-r"></image>
			</view>
		</view>
		<view class="colorf fs14 font-weight tcdl" @tap="logout">退出登录</view>
	</view>
</template>

<script>
	import uploadimg from '@/api/upload/index.js'
	import local_userinfo from '@/util/user/local-userinfo.js'
	export default {
		data() {
			return {
				headimg:''
			};
		},
		onShow() {
			this.init();
		},
		onLoad() {
			// #ifdef MP-WEIXIN
			uni.hideShareMenu()
			// #endif
		},
		methods:{
			init() {
				let user = local_userinfo.getUserinfo()
				if (user) {
					this.headimg = user.headimg || 'https://res.bestcake.com/m-images/order/mw-person-tx.png'
					// this.nickname = user.loginname || user.phone;
					// this.usertag = ''
					// this.balance = user.balance || 0
					// this.loginstate = true
				} else {
					this.headimg = this.$resBaseurl + '/act/mrhappy/user.png?v=' + (new Date()).getHours();
					// this.nickname = "未登录"
					// this.loginstate = false
				}
			},
			logout() {
				let that = this
				uni.showModal({
					content: "是否退出当前账号？",
					confirmText: "继续退出",
					success(res) {
						if (res.confirm)
							that.$checkLoginState.logout()
					}
				})
			},
			resetLoginPwd() {
				uni.navigateTo({
					url: '/pages/user/resetpwd'
				})
			},
			changeOtherHeadimg() {
				let user = local_userinfo.getUserinfo()
				uploadimg.uploadImage(user, () => {
					this.init()
				})
			},
		}
	}
</script>

<style lang="scss">
.content{
	.my_list {
	    width: 92vw;
	    padding: 4.4vw 4vw;
	    border-bottom: 1px solid #f6f6f6;
	    background: white;
		height: 5vw;
		.my_lists{
			height: 5vw;
			line-height: 5vw;
		}
		.listimg {
			display: block;
			width: 5vw;
			height: 5vw;
			margin-right: 2.667vw;
		}
		.listimg2{
			display: block;
			width: 10vw;
			height: 10vw;
			border-radius: 50%;
			margin-top: -2.25vw;
			margin-right: 2.667vw;
		}
	}
	.tcdl{
		width: 80vw;
		margin: 4vw auto;
		background: #00449F;
		height: 13vw;
		border-radius: 1.6vw;
		line-height: 13vw;
		text-align: center;
	}
}
</style>
